<template>
  <div>
    <el-dialog v-el-drag-dialog title="Fragment" width="60%" :visible.sync="dialogVisible">
      <el-carousel indicator-position="outside" :autoplay="false">
        <el-carousel-item v-for="item in rows" :key="item.id">
          <el-container>
            <el-main>
              <MarkdownViewer :content="item.fragment" />
            </el-main>
          </el-container>
        </el-carousel-item>
      </el-carousel>
    </el-dialog>
  </div>
</template>

<script>
import elDragDialog from '@/directive/el-drag-dialog'
import MarkdownViewer from '@/components/MarkdownViewer'

export default {
  name: 'Preview',
  directives: { elDragDialog },
  components: { MarkdownViewer },
  data() {
    return {
      rows: [],
      dialogVisible: false
    }
  },
  created() {
    this.$on('open', function(rows) {
      this.dialogVisible = true
      this.rows = rows
    })
  },
  methods: {}
}
</script>

<style lang="scss" scoped>
.el-main {
  height: 300px;
  margin-left: 5%;
  margin-right: 5%;
  padding: 0px 15px 15px 15px !important;
}
</style>
